using AppToolKit.Core.Text;
using System;
using System.Collections.Generic;
using System.Text;
namespace AppToolKit.Data
{
	public abstract class TextQuery
	{
		protected StringBuilder sb_;
		protected TextQuery(string sql)
		{
			this.sb_ = new StringBuilder(sql);
		}
		protected TextQuery()
		{
			this.sb_ = new StringBuilder();
		}
		public void Append(string value)
		{
			this.sb_.Append(value);
		}
		public void AppendLine(string value)
		{
			this.sb_.AppendLine(value);
		}
		public void AppendFormat(string format, params object[] args)
		{
			List<object> list = new List<object>();
			for (int i = 0; i < args.Length; i++)
			{
				args[i] = this.ProcessArgs(args[i]);
			}
			this.sb_.AppendFormat(format, args);
		}
		protected abstract string ProcessArgs(object arg);
		public void AppendFormat(string format, IDictionary<string, object> dict)
		{
			Dictionary<string, object> dictionary = new Dictionary<string, object>();
			foreach (string current in dict.Keys)
			{
				dictionary[current] = this.ProcessArgs(dict[current]);
			}
			this.sb_.Append(StringUtils.Format(format, dictionary));
		}
	}
}
